home *** CD-ROM | disk | FTP | other *** search
/ Game.EXE 2001 January / execd1200.iso / Shareware / Blocks 3 / setup.exe / Source / MENU.C < prev    next >
Encoding:
C/C++ Source or Header  |  2000-01-06  |  8.8 KB  |  334 lines

  1. #include <allegro.h>
  2. #include <jgmod.h>
  3. #include <blocks3.h>
  4.  
  5. void In_Game_Menu(void)
  6. {
  7.  BITMAP *temp2 = create_bitmap(200, 300);
  8.  int item, game_menu_exit;
  9.  int i, j;
  10.  
  11.  blit(screen, temp, 0, 0, 0, 0, 640, 480);
  12.  
  13.  rect(temp2, 0, 0, 199, 299, 0);
  14.  
  15.  game_menu_exit = 0;
  16.  item = 0;
  17.  
  18.  rectfill(temp2, 1, 1, 198, 298, 7);
  19.  rectfill(temp2, 10, 10, 189, 20, makecol(128, 128, 128));
  20.  rectfill(temp2, 10, 279, 189, 289, makecol(128, 128, 128));
  21.  rect(temp2, 10, 10, 189, 20, 0);
  22.  rect(temp2, 10, 279, 189, 289, 0);
  23.  
  24.  rectfill(temp2, 10, item*40 + 35, 190, item*40 + 65, makecol(180, 180, 255));
  25.  text_mode(-1);
  26.  
  27.  textprintf_centre(temp2, fonts[0].dat, 100, 35,  0, "Return");
  28.  textprintf_centre(temp2, fonts[0].dat, 100, 75, 0, "Restart");
  29.  textprintf_centre(temp2, fonts[0].dat, 100, 115, 0, "Level");
  30.  textprintf_centre(temp2, fonts[0].dat, 100, 155, 0, "Options");
  31.  textprintf_centre(temp2, fonts[0].dat, 100, 195, 0, "Music");
  32.  textprintf_centre(temp2, fonts[0].dat, 100, 235, 0, "Exit");
  33.  
  34.  for (i = -200; i < 230; i+=10)
  35.  {
  36.   blit(temp, screen, i - 10, 100, i-10, 100, 10, 300);
  37.   blit(temp2, screen, 0, 0, i, 100, 200, 300);
  38.   while (time_count < 1);
  39.   time_count = 0;
  40.  }
  41.  
  42.  while (key[KEY_ESC]);
  43.  
  44.  while(!game_menu_exit)
  45.  {
  46.   rectfill(temp2, 1, 1, 198, 298, 7);
  47.   rectfill(temp2, 10, 10, 189, 20, makecol(128, 128, 128));
  48.   rectfill(temp2, 10, 279, 189, 289, makecol(128, 128, 128));
  49.   rect(temp2, 10, 10, 189, 20, 0);
  50.   rect(temp2, 10, 279, 189, 289, 0);
  51.  
  52.   rectfill(temp2, 10, item*40 + 35, 190, item*40 + 65, makecol(180, 180, 255));
  53.   text_mode(-1);
  54.  
  55.   textprintf_centre(temp2, fonts[0].dat, 100, 35,  0, "Return");
  56.   textprintf_centre(temp2, fonts[0].dat, 100, 75, 0, "Restart");
  57.   textprintf_centre(temp2, fonts[0].dat, 100, 115, 0, "Level");
  58.   textprintf_centre(temp2, fonts[0].dat, 100, 155, 0, "Options");
  59.   textprintf_centre(temp2, fonts[0].dat, 100, 195, 0, "Music");
  60.   textprintf_centre(temp2, fonts[0].dat, 100, 235, 0, "Exit");
  61.  
  62.   blit(temp2, screen, 0, 0, 220, 100, 200, 300);
  63.  
  64.   while ((!key[KEY_ESC]) && (!key[KEY_UP]) && (!key[KEY_DOWN]) && (!key[KEY_ENTER]));
  65.  
  66.   if (key[KEY_ESC])
  67.   {
  68.    play_sample(sfx[SFX_FALL].dat, 255, 128, 1000, 0);
  69.    item = 0;
  70.    game_menu_exit = 1;
  71.   }
  72.  
  73.   if (key[KEY_ENTER])
  74.   {
  75.    game_menu_exit = 1;
  76.    play_sample(sfx[SFX_FALL].dat, 255, 128, 1000, 0);
  77.   }
  78.  
  79.   if (key[KEY_UP]) item--;
  80.   if (key[KEY_DOWN]) item++;
  81.   play_sample(sfx[SFX_CLICK].dat, 255, 128, 1000, 0);
  82.  
  83.   if (item < 0) item = 5;
  84.   if (item > 5) item = 0;
  85.  
  86.   while ((key[KEY_ESC]) || (key[KEY_UP]) || (key[KEY_DOWN]) || (key[KEY_ENTER]));
  87.  }
  88.  
  89.  for (i = 220; i < 650; i+=10)
  90.  {
  91.   blit(temp, screen, i - 10, 100, i-10, 100, 10, 300);
  92.   blit(temp2, screen, 0, 0, i, 100, 200, 300);
  93.   while (time_count < 1);
  94.   time_count = 0;
  95.  }
  96.  
  97.  if (item == 0) blit(temp, screen, 0, 0, 0, 0, 640, 480);
  98.  if (item == 2)
  99.  {
  100.   Change_Levels();
  101.   if (game_exit == 2)
  102.   {
  103.    Maps_to_Map(lev);
  104.    Draw_Map();
  105.    Init_Level();
  106.    Map_Setup();
  107.    game_exit = 0;
  108.   }
  109.   blit(temp, screen, 0, 0, 0, 0, 640, 480);
  110.  }
  111.  if (item == 3) Options_Menu();
  112.  
  113.  if (item == 1)
  114.  {
  115.   Maps_to_Map(lev);
  116.   Draw_Map();
  117.   Init_Level();
  118.   Map_Setup();
  119.   blit(temp, screen, 0, 0, 0, 0, 640, 480);
  120.  }
  121.  
  122.  if (item == 4) Music_Menu();
  123.  
  124.  if (item == 5) game_exit = 2;
  125. }
  126.  
  127. void Options_Menu(void)
  128. {
  129.  BITMAP *temp2 = create_bitmap(200, 230);
  130.  int item, options_exit, i;
  131.  
  132.  blit(screen, temp, 0, 0, 0, 0, 640, 480);
  133.  
  134.  rect(temp2, 0, 0, 199, 229, 0);
  135.  
  136.  rectfill(temp2, 1, 1, 198, 228, 7);
  137.  rectfill(temp2, 10, 10, 189, 20, makecol(128, 128, 128));
  138.  rectfill(temp2, 10, 210, 189, 220, makecol(128, 128, 128));
  139.  rect(temp2, 10, 10, 189, 20, 0);
  140.  rect(temp2, 10, 210, 189, 220, 0);
  141.  
  142.  rectfill(temp2, 10, item*40 + 40, 190, item*40 + 70, makecol(180, 180, 255));
  143.  text_mode(-1);
  144.  
  145.  textprintf_centre(temp2, fonts[0].dat, 100, 40,  0, "Music Vol");
  146.  textprintf_centre(temp2, fonts[0].dat, 100, 80, 0, "SFX Vol");
  147.  textprintf_centre(temp2, fonts[0].dat, 100, 120, 0, "Return");
  148.  
  149.  for (i = -200; i < 230; i+=10)
  150.  {
  151.   blit(temp, screen, i - 10, 100, i-10, 100, 10, 230);
  152.   blit(temp2, screen, 0, 0, i, 100, 200, 230);
  153.   while (time_count < 1);
  154.   time_count = 0;
  155.  }
  156.  
  157.  options_exit = 0;
  158.  item = 0;
  159.  
  160.  while (!options_exit)
  161.  {
  162.   rectfill(temp2, 1, 1, 198, 228, 7);
  163.   rectfill(temp2, 10, 10, 189, 20, makecol(128, 128, 128));
  164.   rectfill(temp2, 10, 210, 189, 220, makecol(128, 128, 128));
  165.   rect(temp2, 10, 10, 189, 20, 0);
  166.   rect(temp2, 10, 210, 189, 220, 0);
  167.  
  168.   rectfill(temp2, 10, item*40 + 40, 190, item*40 + 70, makecol(180, 180, 255));
  169.   text_mode(-1);
  170.  
  171.   textprintf_centre(temp2, fonts[0].dat, 100, 40,  0, "Music: %d", mus_vol*100/255);
  172.   textprintf_centre(temp2, fonts[0].dat, 100, 80, 0, "CD: %d", cd_vol*100/255);
  173.   textprintf_centre(temp2, fonts[0].dat, 100, 120, 0, "SFX: %d", sfx_vol*100/255);
  174.   textprintf_centre(temp2, fonts[0].dat, 100, 160, 0, "Return");
  175.  
  176.   blit(temp2, screen, 0, 0, 220, 100, 200, 230);
  177.  
  178.   while ((!key[KEY_ESC]) && (!key[KEY_UP]) && (!key[KEY_DOWN]) &&
  179.          (!key[KEY_LEFT]) && (!key[KEY_RIGHT]) &&
  180.          (!key[KEY_ENTER]));
  181.  
  182.   if (key[KEY_ESC])
  183.   {
  184.    play_sample(sfx[SFX_FALL].dat, 255, 128, 1000, 0);
  185.    item = 0;
  186.    options_exit = 1;
  187.   }
  188.  
  189.   if ((key[KEY_ENTER]) || (key[KEY_RIGHT]))
  190.   {
  191.    if (item == 0) mus_vol+=3;
  192.    if (item == 1) cd_vol+=3;
  193.    if (item == 2) sfx_vol+=3;
  194.  
  195.    if (item == 3)
  196.    {
  197.     options_exit = 1;
  198.     play_sample(sfx[SFX_FALL].dat, 255, 128, 1000, 0);
  199.    }
  200.  
  201.    time_count = 0;
  202.    while (time_count < 10);
  203.   }
  204.  
  205.   if (key[KEY_LEFT])
  206.   {
  207.    if (item == 0) mus_vol-=3;
  208.    if (item == 1) cd_vol-=3;
  209.    if (item == 2) sfx_vol-=3;
  210.  
  211.    time_count = 0;
  212.    while (time_count < 10);
  213.   }
  214.  
  215.   if (mus_vol < 0) mus_vol = 0;
  216.   if (sfx_vol < 0) sfx_vol = 0;
  217.   if (cd_vol < 0) cd_vol = 0;
  218.  
  219.   if (mus_vol > 255) mus_vol = 255;
  220.   if (sfx_vol > 255) sfx_vol = 255;
  221.   if (cd_vol > 255) cd_vol = 255;
  222.  
  223.   set_volume(sfx_vol, 0);
  224.   set_mod_volume(mus_vol);
  225.   cd_set_volume(cd_vol, cd_vol);
  226.  
  227.   if (key[KEY_UP]) item--;
  228.   if (key[KEY_DOWN]) item++;
  229.   play_sample(sfx[SFX_CLICK].dat, 255, 128, 1000, 0);
  230.  
  231.   if (item < 0) item = 3;
  232.   if (item > 3) item = 0;
  233.  
  234.   while ((key[KEY_ESC]) || (key[KEY_UP]) || (key[KEY_DOWN]) ||
  235.          (key[KEY_ENTER]));
  236.  }
  237.  
  238.  for (i = 220; i < 650; i+=10)
  239.  {
  240.   blit(temp, screen, i - 10, 100, i-10, 100, 10, 230);
  241.   blit(temp2, screen, 0, 0, i, 100, 200, 230);
  242.   while (time_count < 1);
  243.   time_count = 0;
  244.  }
  245. }
  246.  
  247. void Music_Menu(void)
  248. {
  249.  BITMAP *temp2 = create_bitmap(200, 190);
  250.  int item, music_exit, i;
  251.  
  252.  blit(screen, temp, 0, 0, 0, 0, 640, 480);
  253.  
  254.  rect(temp2, 0, 0, 199, 189, 0);
  255.  
  256.  rectfill(temp2, 1, 1, 198, 188, 7);
  257.  rectfill(temp2, 10, 10, 189, 20, makecol(128, 128, 128));
  258.  rectfill(temp2, 10, 170, 189, 180, makecol(128, 128, 128));
  259.  rect(temp2, 10, 10, 189, 20, 0);
  260.  rect(temp2, 10, 170, 189, 180, 0);
  261.  
  262.  rectfill(temp2, 10, item*40 + 40, 190, item*40 + 70, makecol(180, 180, 255));
  263.  text_mode(-1);
  264.  
  265.  textprintf_centre(temp2, fonts[0].dat, 100, 40,  0, "CD Player", mus_vol*100/255);
  266.  textprintf_centre(temp2, fonts[0].dat, 100, 80, 0, "MOD Music", sfx_vol*100/255);
  267.  textprintf_centre(temp2, fonts[0].dat, 100, 120, 0, "Return");
  268.  
  269.  for (i = -200; i < 230; i+=10)
  270.  {
  271.   blit(temp, screen, i - 10, 100, i-10, 100, 10, 190);
  272.   blit(temp2, screen, 0, 0, i, 100, 200, 190);
  273.   while (time_count < 1);
  274.   time_count = 0;
  275.  }
  276.  
  277.  music_exit = 0;
  278.  item = 0;
  279.  
  280.  while (!music_exit)
  281.  {
  282.   rectfill(temp2, 1, 1, 198, 188, 7);
  283.   rectfill(temp2, 10, 10, 189, 20, makecol(128, 128, 128));
  284.   rectfill(temp2, 10, 170, 189, 180, makecol(128, 128, 128));
  285.   rect(temp2, 10, 10, 189, 20, 0);
  286.   rect(temp2, 10, 170, 189, 180, 0);
  287.  
  288.   rectfill(temp2, 10, item*40 + 40, 190, item*40 + 70, makecol(180, 180, 255));
  289.   text_mode(-1);
  290.  
  291.   textprintf_centre(temp2, fonts[0].dat, 100, 40,  0, "CD Player", mus_vol*100/255);
  292.   textprintf_centre(temp2, fonts[0].dat, 100, 80, 0, "MOD Music", sfx_vol*100/255);
  293.   textprintf_centre(temp2, fonts[0].dat, 100, 120, 0, "Return");
  294.  
  295.   blit(temp2, screen, 0, 0, 220, 100, 200, 300);
  296.  
  297.   while ((!key[KEY_ESC]) && (!key[KEY_UP]) && (!key[KEY_DOWN]) && (!key[KEY_ENTER]));
  298.  
  299.   if (key[KEY_ESC])
  300.   {
  301.    play_sample(sfx[SFX_FALL].dat, 255, 128, 1000, 0);
  302.    item = -1;
  303.    music_exit = 1;
  304.   }
  305.  
  306.   if (key[KEY_ENTER])
  307.   {
  308.    music_exit = 1;
  309.   }
  310.  
  311.   if (key[KEY_UP]) item--;
  312.   if (key[KEY_DOWN]) item++;
  313.   play_sample(sfx[SFX_CLICK].dat, 255, 128, 1000, 0);
  314.  
  315.   if (item < 0) item = 2;
  316.   if (item > 2) item = 0;
  317.  
  318.   while ((key[KEY_ESC]) || (key[KEY_UP]) || (key[KEY_DOWN]) || (key[KEY_ENTER]));
  319.  }
  320.  
  321.  for (i = 220; i < 650; i+=10)
  322.  {
  323.   blit(temp, screen, i - 10, 100, i-10, 100, 10, 190);
  324.   blit(temp2, screen, 0, 0, i, 100, 200, 190);
  325.   while (time_count < 1);
  326.   time_count = 0;
  327.  }
  328.  
  329.  if (item == 0) CD_Player();
  330.  if (item == 1) Mod_Music();
  331. }
  332.  
  333.  
  334.